package scjp.preparation.exam;

import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class TestThread {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// new MyThread("oops");
		Lock lock1 = new ReentrantLock();
		Lock lock2 = new ReentrantLock();
		try {
			System.out.println("Going to lock...");
			System.out.println("In critical section");
		} finally {
			lock2.unlock();
			System.out.println("Unlocking ...");
		}
	}

}

class MyThread extends Thread {
	public MyThread(String name) {
		this.setName(name);
		start();
		System.out.println("in ctor " + getName());
	}

	public void start() {
		System.out.println("in start " + getName());
	}

	public void run() {
		System.out.println("in run " + getName());
	}
}